package com.my.serviceimpl;

import com.my.bean.FoodRelation;
import com.my.bean.ResultPage;
import com.my.bean.VoPage;
import com.my.mapper.FoodRelationMapper;
import com.my.service.FoodRelationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 月子餐单 服务实现类
 * </p>
 *
 * @author 闫亚茹
 * @since 2018-09-09
 */
@Service
public class FoodRelationServiceImpl extends ServiceImpl<FoodRelationMapper, FoodRelation> implements FoodRelationService {



    @Override
    public ResultPage<FoodRelation> selectMyPage(VoPage voPage,String homeId) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        paramMap.put("homeId",homeId);

        List<FoodRelation> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<FoodRelation> resultPage=new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }
}
